//
//  ContryDetailCollectionViewCell.m
//  PTravel
//
//  Created by dllo on 15/11/18.
//  Copyright © 2015年 李涵. All rights reserved.
//

#import "CountryDetailCollectionViewCell.h"

@implementation CountryDetailCollectionViewCell
- (void)dealloc
{
    [_image release];
    [_title release];
    [_discount release];
    [_priceLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, BOUNDS.size.width/4+10, 76)];
    self.image.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(self.image.frame.size.width + 10, 0, BOUNDS.size.width-self.image.frame.size.width-15, 50)];
    self.title.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.title];
    [_title release];
    
    self.discountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.title.frame.origin.x, self.title.frame.origin.y+50, 60, 30)];
    self.discountLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.discountLabel];
    [_discountLabel release];
    
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(BOUNDS.size.width-80, self.title.frame.origin.y+50, 74, 30)];
    self.priceLabel.textColor = [UIColor redColor];
    self.priceLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.priceLabel];
    [_priceLabel release];
}

- (void)setDiscount:(New_discount *)discount
{
    if (_discount != discount) {
        [_discount release];
        _discount = [discount retain];
    }
    self.title.text = discount.title;
    self.title.numberOfLines = 0;
    self.discountLabel.text = discount.priceoff;
    self.priceLabel.text = [AppTools flattenHTML:discount.price];
    NSURL *url = [NSURL URLWithString:discount.photo];
    [self.image sd_setImageWithURL:url placeholderImage:IMAGE];
    self.title.textColor = TEXTCOLOR;
    self.discountLabel.textColor = TEXTCOLOR;
}


@end
